x86/shadow: Use the pagewalk reserved bits helpers
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 5 Jul 2016 09:40:21 +0000 (10:40 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Mon, 27 Mar 2017 10:49:25 +0000 (11:49 +0100)
commitf9964cae8c3ee1c486f14022163e72e2ffd9fe04
tree309ed810d26875fdab1877f7cf124c2567dedea0
parent4c5d78a10dc89427140a50a1df5a0b8e9f073e82
x86/shadow: Use the pagewalk reserved bits helpers

The shadow logic should not create a valid/present shadow of a guest PTE which
contains reserved bits from the guests point of view.  It is not guaranteed
that the hardware pagewalk will come to the same conclusion, and raise a
pagefault.

Shadows created on demand from the pagefault handler are fine because the
pagewalk over the guest tables will have injected the fault into the guest
rather than creating a shadow.

However, shadows created by sh_resync_l1() and sh_prefetch() haven't undergone
a pagewalk and need to account for reserved bits before creating the shadow.

In practice, this means a 3-level guest could previously cause PTEs with bits
63:52 set to be shadowed (and discarded).  This PTE should cause #PF[RSVD]
when encountered by hardware, but the installed shadow is valid and hardware
doesn't fault.

Reuse the pagewalk reserved bits helpers, and assert in
l?e_propagate_from_guest() that shadows are not attempted to be created with
reserved bits set.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/shadow/multi.c